/**
 * 
 */
package edu.gatech.cuckoo;

import java.util.Map.Entry;

/**
 * @author Dale Avery
 * @param <E>
 * 
 */
class GenericHashFunction<K, V> implements HashFunction<K, V> {

	// Makes this hash function generate unique values.
	private int uniqueFactor;

	/**
	 * Constructs a new GenericHashFunction.
	 * 
	 * @param factor
	 *            A number that will change this hash function's hash codes.
	 */
	public GenericHashFunction(int factor) {
		this.uniqueFactor = Math.abs(factor);
	}

	@Override
	public int hashCode(K key) {
		int result = 1;
		result = uniqueFactor * result + ((key == null) ? 0 : key.hashCode());
		return result;
	}

	// Methods used for testing. DO NOT TOUCH!
	public int getFactor() {
		return uniqueFactor;
	}

	public void setFactor(int newFactor) {
		this.uniqueFactor = newFactor;
	}

}
